package com.ag.zrt.action;

import javax.annotation.Resource;

import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.ag.bean.TbEventLevel;
import com.ag.common.BaseAction;
import com.ag.zrt.service.EventLevelService;
@Controller("addEventLevelAction")
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public class AddEventLevelAction extends BaseAction {
	private static final long serialVersionUID = 6147847646504096596L;

	private String el;
	private String elColor;
	private String msg;
	private String errorDetail;
	@Resource(name = "EventLevelService")
	private EventLevelService eventLevelService;

	@Override
	public String execute() {
		// 实例化实体类，实例化后内存内容是空
		TbEventLevel eventLevel = new TbEventLevel();

		try {

			eventLevel.setElEventLevel(el);
			eventLevel.setElColor(elColor);
			eventLevelService.save(eventLevel);
			msg = "添加成功";
			errorDetail = "";
			return "add_el_succ";

		} catch (Exception e) {
			errorDetail = e.toString();
			// e.printStackTrace();
			// System.out.println(error_detail+"*****************************************************************");
			msg = "存偖失败";
			return "add_el_failed";
		}
	}

	public String getErrorDetail() {
		return errorDetail;
	}

	public String getMsg() {
		return msg;
	}

	public void setEl(String el) {
		this.el = el;
	}

	public void setElColor(String elColor) {
		this.elColor = elColor;
	}

	public void setEventLevelService(EventLevelService eventLevelService) {
		this.eventLevelService = eventLevelService;
	}

}
